<template>
	<view class="news tn-safe-area-inset-bottom">
		<view class="tbas-box tn-flex">
			<view class="tbas-item tn-text-center" :class="[tbaIndex==index?'active':'']"
			 v-for="(item,index) in tabslist" :key="index"  @click="onTabs(index)">
				{{item.name}}
			</view>
		</view>
		<view class="">
			<view class="">
				<block v-for="(item, index) in list" :key="index">
					<view class="article-shadow tn-margin tn-bg-white" @click="navDetails(item)">
						<view class="tn-flex">

							<view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
								<view class="tn-text-lg tn-text-bold clamp-text-1 tn-text-justify">
									<text class="">{{ item.title }}</text>
								</view>
								<view class="tn-padding-top-xs" style="min-height: 90rpx;">
									<text class="tn-text-df tn-color-gray clamp-text-2 tn-text-justify">
										<!-- {{ item.desc }} -->
									</text>
								</view>
								<view class="tn-flex tn-flex-row-between tn-flex-col-between tn-margin-top-sm">
									<view
										class="justify-content-item tn-tag-content__item tn-margin-right tn-text-sm tn-text-bold">
										<text class="tn-tag-content__item--prefix">#</text> {{ item.createTime }}
									</view>

								</view>
							</view>
							<view class="image-pic tn-margin-sm" :style="'background-image:url(' + item.cover + ')'">
								<view class="image-article">
								</view>
							</view>
						</view>
					</view>
				</block>

			</view>
		</view>
		<view class='tn-tabbar-height'></view>
	</view>
</template>

<script>
	import {
		Getnews
	} from '@/api/consultation/index'

	export default {
		data() {
			return {
				name: '',
				list: [],
				page: 1,
				row: 10,
				total: "",
				tabslist:[
					{
						name:"全部",
						type:null
					},
					{
						name:"产业活动",
						type:'1'
					},
					{
						name:"党建活动",
						type:'2'
					},
					{
						name:"工会活动",
						type:'3'
					},
				],
				tbaIndex:0
			}
		},
		onShow() {
			this.getnews()
		},
		onReachBottom() {
			if (this.total <= this.list.length) {
				uni.showToast({
					icon: 'none',
					duration: 2000
				})
				return
			}
			this.page++
			this.getnews()
		},
		methods: {
			onTabs(e){
				if(this.tbaIndex==e) return
				this.tbaIndex=e
				this.getnews()
			},
			navDetails(item) {
				uni.navigateTo({
					url: `/subcontract/consultation/details?id=${item.id}`
				});
			},
			getnews() {
				let obj = {
					name: this.name,
					page: this.page,
					row: this.row,
			
				}
				this.tbaIndex!==0?	obj.type=this.tabslist[this.tbaIndex].type:''
				uni.showLoading({
					title: '加载中'
				})
				Getnews(obj).then((res) => {
					if (this.page !== 1) {
						this.list = this.list.concat(res.data)
					} else {
						this.list = res.data
					}
					this.total = res.total
					uni.hideLoading();
				}, error => {
					uni.hideLoading();
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.news {
		min-height: 100vh;
	}
    .tbas-box{
		.tbas-item{
			width:25%;
			line-height: 80rpx;
			border-bottom: 2rpx solid #d4d4d4;
			border-right:2rpx solid #d4d4d4;
		}
		.active{
			background-color: #3dd5ff;
			color:#fff;
		}
	}
	/* 自定义导航栏内容 start */
	
	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 120rpx;
		height: calc(140rpx + env(safe-area-inset-bottom) / 2);
		height: calc(140rpx + constant(safe-area-inset-bottom));
	}

	/* 文字截取*/
	.clamp-text-1 {
		-webkit-line-clamp: 1;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.clamp-text-2 {
		-webkit-line-clamp: 2;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	/* 镂空 */
	.tnloukong {
		position: fixed;
		padding: 4rpx 8rpx;
		bottom: 220rpx;
		border-radius: 5rpx;
		left: 30rpx;
		font-weight: bold;
		text-align: center;
		z-index: 1000;
		background: rgba(255, 255, 255, 1);
		color: #070707;
		/* mix-blend-mode: overlay; difference;lighten;hue*/
		mix-blend-mode: lighten;

	}

	/* 阴影 start*/
	.home-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.article-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	/* 文字截取*/
	.clamp-text-1 {
		-webkit-line-clamp: 1;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.clamp-text-2 {
		-webkit-line-clamp: 2;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.image-design {
		padding: 140rpx 0rpx;
		font-size: 40rpx;
		font-weight: 300;
		position: relative;
	}

	.image-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 10rpx;
	}

	/* 文章内容 end*/
</style>